package o;

import android.os.Handler;
import android.os.Handler.Callback;
import android.os.HandlerThread;
import android.os.Looper;
import android.os.Message;
import android.util.Pair;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.IllegalSeekPositionException;
import com.google.android.exoplayer2.Renderer;
import com.google.android.exoplayer2.source.TrackGroupArray;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import o.alb.e;

final class abf implements Callback, o.aih.c, e, o.aim.c, o.aba.b, o.abn.a {
    private final abr.e ʻ;
    private final ams ʻॱ;
    private final ald ʼ;
    private boolean ʼॱ;
    private final Handler ʽ;
    private boolean ʽॱ;
    private aim ʾ;
    private Renderer[] ʿ;
    private boolean ˈ;
    private int ˉ;
    private final Renderer[] ˊ;
    private int ˊˊ;
    private boolean ˊˋ;
    private final d ˊॱ;
    private b ˊᐝ;
    private final alb ˋ;
    private long ˋˊ;
    private final aba ˋॱ;
    private final abi ˎ;
    private int ˎˎ;
    private final ala ˏ;
    private final long ˏॱ;
    private final o.abr.c ͺ;
    private final abm[] ॱ;
    private final boolean ॱˊ;
    private abp ॱˋ;
    private final abo ॱˎ = new abo();
    private final amx ॱॱ;
    private final ArrayList<a> ॱᐝ;
    private final HandlerThread ᐝ;
    private abv ᐝॱ;

    static final class a implements Comparable<a> {
        public int ˊ;
        public long ˋ;
        public final abn ˎ;
        @Nullable
        public Object ˏ;

        public /* synthetic */ int compareTo(@NonNull Object obj) {
            return ˋ((a) obj);
        }

        public a(abn o_abn) {
            this.ˎ = o_abn;
        }

        public void ˏ(int i, long j, Object obj) {
            this.ˊ = i;
            this.ˋ = j;
            this.ˏ = obj;
        }

        public int ˋ(@NonNull a aVar) {
            if ((this.ˏ == null ? 1 : 0) != (aVar.ˏ == null ? 1 : 0)) {
                if (this.ˏ != null) {
                    return -1;
                }
                return 1;
            } else if (this.ˏ == null) {
                return 0;
            } else {
                int i = this.ˊ - aVar.ˊ;
                return i == 0 ? anr.ˏ(this.ˋ, aVar.ˋ) : i;
            }
        }
    }

    static final class b {
        public final int ˊ;
        public final abr ˏ;
        public final long ॱ;

        public b(abr o_abr, int i, long j) {
            this.ˏ = o_abr;
            this.ˊ = i;
            this.ॱ = j;
        }
    }

    static final class c {
        public final Object ˋ;
        public final aim ˎ;
        public final abr ॱ;

        public c(aim o_aim, abr o_abr, Object obj) {
            this.ˎ = o_aim;
            this.ॱ = o_abr;
            this.ˋ = obj;
        }
    }

    static final class d {
        private boolean ˊ;
        private int ˋ;
        private int ˎ;
        private abp ˏ;

        private d() {
        }

        public boolean ˎ(abp o_abp) {
            return o_abp != this.ˏ || this.ˋ > 0 || this.ˊ;
        }

        public void ˋ(abp o_abp) {
            this.ˏ = o_abp;
            this.ˋ = 0;
            this.ˊ = false;
        }

        public void ˋ(int i) {
            this.ˋ += i;
        }

        public void ˎ(int i) {
            boolean z = true;
            if (!this.ˊ || this.ˎ == 4) {
                this.ˊ = true;
                this.ˎ = i;
                return;
            }
            if (i != 4) {
                z = false;
            }
            amm.ˊ(z);
        }
    }

    public /* synthetic */ void ˏ(aiw o_aiw) {
        ˋ((aih) o_aiw);
    }

    public abf(Renderer[] rendererArr, alb o_alb, ala o_ala, abi o_abi, ald o_ald, boolean z, int i, boolean z2, Handler handler, ams o_ams) {
        this.ˊ = rendererArr;
        this.ˋ = o_alb;
        this.ˏ = o_ala;
        this.ˎ = o_abi;
        this.ʼ = o_ald;
        this.ˈ = z;
        this.ˊˊ = i;
        this.ˊˋ = z2;
        this.ʽ = handler;
        this.ʻॱ = o_ams;
        this.ˏॱ = o_abi.ॱ();
        this.ॱˊ = o_abi.ʽ();
        this.ᐝॱ = abv.ॱ;
        this.ॱˋ = abp.ˊ(-9223372036854775807L, o_ala);
        this.ˊॱ = new d();
        this.ॱ = new abm[rendererArr.length];
        for (int i2 = 0; i2 < rendererArr.length; i2++) {
            rendererArr[i2].ˊ(i2);
            this.ॱ[i2] = rendererArr[i2].ˎ();
        }
        this.ˋॱ = new aba(this, o_ams);
        this.ॱᐝ = new ArrayList();
        this.ʿ = new Renderer[0];
        this.ʻ = new abr.e();
        this.ͺ = new o.abr.c();
        o_alb.ˎ(this, o_ald);
        this.ᐝ = new HandlerThread("ExoPlayerImplInternal:Handler", -16);
        this.ᐝ.start();
        this.ॱॱ = o_ams.ˊ(this.ᐝ.getLooper(), this);
    }

    public void ˋ(aim o_aim, boolean z, boolean z2) {
        int i;
        int i2 = 1;
        amx o_amx = this.ॱॱ;
        if (z) {
            i = 1;
        } else {
            i = 0;
        }
        if (!z2) {
            i2 = 0;
        }
        o_amx.ˋ(0, i, i2, o_aim).sendToTarget();
    }

    public void ˏ(boolean z) {
        int i;
        amx o_amx = this.ॱॱ;
        if (z) {
            i = 1;
        } else {
            i = 0;
        }
        o_amx.ˋ(1, i, 0).sendToTarget();
    }

    public void ˎ(int i) {
        this.ॱॱ.ˋ(12, i, 0).sendToTarget();
    }

    public void ˊ(abr o_abr, int i, long j) {
        this.ॱॱ.ˎ(3, new b(o_abr, i, j)).sendToTarget();
    }

    public void ˎ(abv o_abv) {
        this.ॱॱ.ˎ(5, o_abv).sendToTarget();
    }

    public void ˋ(boolean z) {
        int i;
        amx o_amx = this.ॱॱ;
        if (z) {
            i = 1;
        } else {
            i = 0;
        }
        o_amx.ˋ(6, i, 0).sendToTarget();
    }

    public synchronized void ˏ(abn o_abn) {
        if (this.ʽॱ) {
            amz.ˏ("ExoPlayerImplInternal", "Ignoring messages sent after release.");
            o_abn.ˊ(false);
        } else {
            this.ॱॱ.ˎ(14, o_abn).sendToTarget();
        }
    }

    public synchronized void ˏ() {
        if (!this.ʽॱ) {
            this.ॱॱ.ˋ(7);
            Object obj = null;
            while (!this.ʽॱ) {
                try {
                    wait();
                } catch (InterruptedException e) {
                    obj = 1;
                }
            }
            if (obj != null) {
                Thread.currentThread().interrupt();
            }
        }
    }

    public Looper ˊ() {
        return this.ᐝ.getLooper();
    }

    public void ˏ(aim o_aim, abr o_abr, Object obj) {
        this.ॱॱ.ˎ(8, new c(o_aim, o_abr, obj)).sendToTarget();
    }

    public void ˊ(aih o_aih) {
        this.ॱॱ.ˎ(9, o_aih).sendToTarget();
    }

    public void ˋ(aih o_aih) {
        this.ॱॱ.ˎ(10, o_aih).sendToTarget();
    }

    public void ॱ(abq o_abq) {
        this.ॱॱ.ˎ(16, o_abq).sendToTarget();
    }

    public boolean handleMessage(Message message) {
        try {
            boolean z;
            switch (message.what) {
                case 0:
                    boolean z2;
                    boolean z3;
                    aim o_aim = (aim) message.obj;
                    if (message.arg1 != 0) {
                        z2 = true;
                    } else {
                        z2 = false;
                    }
                    if (message.arg2 != 0) {
                        z3 = true;
                    } else {
                        z3 = false;
                    }
                    ˊ(o_aim, z2, z3);
                    break;
                case 1:
                    if (message.arg1 != 0) {
                        z = true;
                    } else {
                        z = false;
                    }
                    ॱ(z);
                    break;
                case 2:
                    ᐝ();
                    break;
                case 3:
                    ˏ((b) message.obj);
                    break;
                case 4:
                    ˋ((abq) message.obj);
                    break;
                case 5:
                    ˊ((abv) message.obj);
                    break;
                case 6:
                    ॱ(message.arg1 != 0, true);
                    break;
                case 7:
                    ʻ();
                    return true;
                case 8:
                    ˎ((c) message.obj);
                    break;
                case 9:
                    ˎ((aih) message.obj);
                    break;
                case 10:
                    ॱ((aih) message.obj);
                    break;
                case 11:
                    ʽ();
                    break;
                case 12:
                    ॱ(message.arg1);
                    break;
                case 13:
                    if (message.arg1 != 0) {
                        z = true;
                    } else {
                        z = false;
                    }
                    ˎ(z);
                    break;
                case 14:
                    ॱ((abn) message.obj);
                    break;
                case 15:
                    ˎ((abn) message.obj);
                    break;
                case 16:
                    ˊ((abq) message.obj);
                    break;
                default:
                    return false;
            }
            ˋ();
        } catch (Throwable e) {
            amz.ˊ("ExoPlayerImplInternal", "Playback error.", e);
            ॱ(false, false);
            this.ʽ.obtainMessage(2, e).sendToTarget();
            ˋ();
        } catch (IOException e2) {
            amz.ˊ("ExoPlayerImplInternal", "Source error.", e2);
            ॱ(false, false);
            this.ʽ.obtainMessage(2, ExoPlaybackException.ˏ(e2)).sendToTarget();
            ˋ();
        } catch (RuntimeException e3) {
            amz.ˊ("ExoPlayerImplInternal", "Internal runtime error.", e3);
            ॱ(false, false);
            this.ʽ.obtainMessage(2, ExoPlaybackException.ˏ(e3)).sendToTarget();
            ˋ();
        }
        return true;
    }

    private void ˏ(int i) {
        if (this.ॱˋ.ʻ != i) {
            this.ॱˋ = this.ॱˋ.ˏ(i);
        }
    }

    private void ˊ(boolean z) {
        if (this.ॱˋ.ʼ != z) {
            this.ॱˋ = this.ॱˋ.ˊ(z);
        }
    }

    private void ˋ() {
        if (this.ˊॱ.ˎ(this.ॱˋ)) {
            this.ʽ.obtainMessage(0, this.ˊॱ.ˋ, this.ˊॱ.ˊ ? this.ˊॱ.ˎ : -1, this.ॱˋ).sendToTarget();
            this.ˊॱ.ˋ(this.ॱˋ);
        }
    }

    private void ˊ(aim o_aim, boolean z, boolean z2) {
        this.ˉ++;
        ˊ(true, z, z2);
        this.ˎ.ˏ();
        this.ʾ = o_aim;
        ˏ(2);
        o_aim.ॱ(this, this.ʼ.ˋ());
        this.ॱॱ.ˋ(2);
    }

    private void ॱ(boolean z) throws ExoPlaybackException {
        this.ʼॱ = false;
        this.ˈ = z;
        if (!z) {
            ॱ();
            ʼ();
        } else if (this.ॱˋ.ʻ == 3) {
            ˎ();
            this.ॱॱ.ˋ(2);
        } else if (this.ॱˋ.ʻ == 2) {
            this.ॱॱ.ˋ(2);
        }
    }

    private void ॱ(int i) throws ExoPlaybackException {
        this.ˊˊ = i;
        if (!this.ॱˎ.ॱ(i)) {
            ʼ(true);
        }
        ʽ(false);
    }

    private void ˎ(boolean z) throws ExoPlaybackException {
        this.ˊˋ = z;
        if (!this.ॱˎ.ˊ(z)) {
            ʼ(true);
        }
        ʽ(false);
    }

    private void ʼ(boolean z) throws ExoPlaybackException {
        o.aim.a aVar = this.ॱˎ.ˋ().ʻ.ˎ;
        long ˊ = ˊ(aVar, this.ॱˋ.ͺ, true);
        if (ˊ != this.ॱˋ.ͺ) {
            this.ॱˋ = this.ॱˋ.ˏ(aVar, ˊ, this.ॱˋ.ˏ, ॱˋ());
            if (z) {
                this.ˊॱ.ˎ(4);
            }
        }
    }

    private void ˎ() throws ExoPlaybackException {
        int i = 0;
        this.ʼॱ = false;
        this.ˋॱ.ˏ();
        Renderer[] rendererArr = this.ʿ;
        int length = rendererArr.length;
        while (i < length) {
            rendererArr[i].ˏ();
            i++;
        }
    }

    private void ॱ() throws ExoPlaybackException {
        this.ˋॱ.ˎ();
        for (Renderer ˎ : this.ʿ) {
            ˎ(ˎ);
        }
    }

    private void ʼ() throws ExoPlaybackException {
        if (this.ॱˎ.ॱॱ()) {
            abj ˋ = this.ॱˎ.ˋ();
            long ˎ = ˋ.ˎ.ˎ();
            if (ˎ != -9223372036854775807L) {
                ॱ(ˎ);
                if (ˎ != this.ॱˋ.ͺ) {
                    this.ॱˋ = this.ॱˋ.ˏ(this.ॱˋ.ॱ, ˎ, this.ॱˋ.ˏ, ॱˋ());
                    this.ˊॱ.ˎ(4);
                }
            } else {
                this.ˋˊ = this.ˋॱ.ˊ();
                long ˏ = ˋ.ˏ(this.ˋˊ);
                ˋ(this.ॱˋ.ͺ, ˏ);
                this.ॱˋ.ͺ = ˏ;
            }
            ˋ = this.ॱˎ.ˊ();
            this.ॱˋ.ॱˊ = ˋ.ˎ();
            this.ॱˋ.ˋॱ = ॱˋ();
        }
    }

    /* JADX WARNING: inconsistent code. */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    private void ᐝ() throws com.google.android.exoplayer2.ExoPlaybackException, java.io.IOException {
        /*
        r15 = this;
        r0 = r15.ʻॱ;
        r4 = r0.ॱ();
        r15.ˋॱ();
        r0 = r15.ॱˎ;
        r0 = r0.ॱॱ();
        if (r0 != 0) goto L_0x001a;
    L_0x0011:
        r15.ॱˊ();
        r0 = 10;
        r15.ˎ(r4, r0);
    L_0x0019:
        return;
    L_0x001a:
        r0 = r15.ॱˎ;
        r6 = r0.ˋ();
        r0 = "doSomeWork";
        o.anp.ॱ(r0);
        r15.ʼ();
        r0 = android.os.SystemClock.elapsedRealtime();
        r2 = 1000; // 0x3e8 float:1.401E-42 double:4.94E-321;
        r8 = r0 * r2;
        r0 = r6.ˎ;
        r1 = r15.ॱˋ;
        r2 = r1.ͺ;
        r10 = r15.ˏॱ;
        r2 = r2 - r10;
        r1 = r15.ॱˊ;
        r0.ˎ(r2, r1);
        r2 = 1;
        r1 = 1;
        r7 = r15.ʿ;
        r10 = r7.length;
        r0 = 0;
        r3 = r1;
        r14 = r0;
        r0 = r2;
        r2 = r14;
    L_0x0048:
        if (r2 >= r10) goto L_0x0081;
    L_0x004a:
        r11 = r7[r2];
        r12 = r15.ˋˊ;
        r11.ˊ(r12, r8);
        if (r0 == 0) goto L_0x007b;
    L_0x0053:
        r0 = r11.ʽॱ();
        if (r0 == 0) goto L_0x007b;
    L_0x0059:
        r0 = 1;
    L_0x005a:
        r1 = r11.ˈ();
        if (r1 != 0) goto L_0x006c;
    L_0x0060:
        r1 = r11.ʽॱ();
        if (r1 != 0) goto L_0x006c;
    L_0x0066:
        r1 = r15.ˋ(r11);
        if (r1 == 0) goto L_0x007d;
    L_0x006c:
        r1 = 1;
    L_0x006d:
        if (r1 != 0) goto L_0x0072;
    L_0x006f:
        r11.ॱॱ();
    L_0x0072:
        if (r3 == 0) goto L_0x007f;
    L_0x0074:
        if (r1 == 0) goto L_0x007f;
    L_0x0076:
        r1 = 1;
    L_0x0077:
        r2 = r2 + 1;
        r3 = r1;
        goto L_0x0048;
    L_0x007b:
        r0 = 0;
        goto L_0x005a;
    L_0x007d:
        r1 = 0;
        goto L_0x006d;
    L_0x007f:
        r1 = 0;
        goto L_0x0077;
    L_0x0081:
        if (r3 != 0) goto L_0x0086;
    L_0x0083:
        r15.ॱˊ();
    L_0x0086:
        r1 = r6.ʻ;
        r8 = r1.ˏ;
        if (r0 == 0) goto L_0x00bf;
    L_0x008c:
        r0 = -9223372036854775807; // 0x8000000000000001 float:1.4E-45 double:-4.9E-324;
        r0 = (r8 > r0 ? 1 : (r8 == r0 ? 0 : -1));
        if (r0 == 0) goto L_0x009d;
    L_0x0095:
        r0 = r15.ॱˋ;
        r0 = r0.ͺ;
        r0 = (r8 > r0 ? 1 : (r8 == r0 ? 0 : -1));
        if (r0 > 0) goto L_0x00bf;
    L_0x009d:
        r0 = r6.ʻ;
        r0 = r0.ᐝ;
        if (r0 == 0) goto L_0x00bf;
    L_0x00a3:
        r0 = 4;
        r15.ˏ(r0);
        r15.ॱ();
    L_0x00aa:
        r0 = r15.ॱˋ;
        r0 = r0.ʻ;
        r1 = 2;
        if (r0 != r1) goto L_0x00f9;
    L_0x00b1:
        r1 = r15.ʿ;
        r2 = r1.length;
        r0 = 0;
    L_0x00b5:
        if (r0 >= r2) goto L_0x00f9;
    L_0x00b7:
        r3 = r1[r0];
        r3.ॱॱ();
        r0 = r0 + 1;
        goto L_0x00b5;
    L_0x00bf:
        r0 = r15.ॱˋ;
        r0 = r0.ʻ;
        r1 = 2;
        if (r0 != r1) goto L_0x00d8;
    L_0x00c6:
        r0 = r15.ॱॱ(r3);
        if (r0 == 0) goto L_0x00d8;
    L_0x00cc:
        r0 = 3;
        r15.ˏ(r0);
        r0 = r15.ˈ;
        if (r0 == 0) goto L_0x00aa;
    L_0x00d4:
        r15.ˎ();
        goto L_0x00aa;
    L_0x00d8:
        r0 = r15.ॱˋ;
        r0 = r0.ʻ;
        r1 = 3;
        if (r0 != r1) goto L_0x00aa;
    L_0x00df:
        r0 = r15.ʿ;
        r0 = r0.length;
        if (r0 != 0) goto L_0x00f6;
    L_0x00e4:
        r0 = r15.ͺ();
        if (r0 != 0) goto L_0x00aa;
    L_0x00ea:
        r0 = r15.ˈ;
        r15.ʼॱ = r0;
        r0 = 2;
        r15.ˏ(r0);
        r15.ॱ();
        goto L_0x00aa;
    L_0x00f6:
        if (r3 != 0) goto L_0x00aa;
    L_0x00f8:
        goto L_0x00ea;
    L_0x00f9:
        r0 = r15.ˈ;
        if (r0 == 0) goto L_0x0104;
    L_0x00fd:
        r0 = r15.ॱˋ;
        r0 = r0.ʻ;
        r1 = 3;
        if (r0 == r1) goto L_0x010b;
    L_0x0104:
        r0 = r15.ॱˋ;
        r0 = r0.ʻ;
        r1 = 2;
        if (r0 != r1) goto L_0x0115;
    L_0x010b:
        r0 = 10;
        r15.ˎ(r4, r0);
    L_0x0110:
        o.anp.ˎ();
        goto L_0x0019;
    L_0x0115:
        r0 = r15.ʿ;
        r0 = r0.length;
        if (r0 == 0) goto L_0x0127;
    L_0x011a:
        r0 = r15.ॱˋ;
        r0 = r0.ʻ;
        r1 = 4;
        if (r0 == r1) goto L_0x0127;
    L_0x0121:
        r0 = 1000; // 0x3e8 float:1.401E-42 double:4.94E-321;
        r15.ˎ(r4, r0);
        goto L_0x0110;
    L_0x0127:
        r0 = r15.ॱॱ;
        r1 = 2;
        r0.ˊ(r1);
        goto L_0x0110;
        */
        throw new UnsupportedOperationException("Method not decompiled: o.abf.ᐝ():void");
    }

    private void ˎ(long j, long j2) {
        this.ॱॱ.ˊ(2);
        this.ॱॱ.ॱ(2, j + j2);
    }

    private void ˏ(b bVar) throws ExoPlaybackException {
        o.aim.a ॱ;
        long j;
        long j2;
        int i;
        this.ˊॱ.ˋ(1);
        Pair ˏ = ˏ(bVar, true);
        if (ˏ == null) {
            ॱ = this.ॱˋ.ॱ(this.ˊˋ, this.ʻ);
            j = -9223372036854775807L;
            j2 = -9223372036854775807L;
            i = 1;
        } else {
            Object obj = ˏ.first;
            j2 = ((Long) ˏ.second).longValue();
            ॱ = this.ॱˎ.ॱ(obj, j2);
            if (ॱ.ˊ()) {
                j = 0;
                i = 1;
            } else {
                j = ((Long) ˏ.second).longValue();
                i = bVar.ॱ == -9223372036854775807L ? 1 : 0;
            }
        }
        try {
            if (this.ʾ == null || this.ˉ > 0) {
                this.ˊᐝ = bVar;
            } else if (j == -9223372036854775807L) {
                ˏ(4);
                ˊ(false, true, false);
            } else {
                long j3;
                if (ॱ.equals(this.ॱˋ.ॱ)) {
                    abj ˋ = this.ॱˎ.ˋ();
                    if (ˋ == null || j == 0) {
                        j3 = j;
                    } else {
                        j3 = ˋ.ˎ.ॱ(j, this.ᐝॱ);
                    }
                    if (C.ˋ(j3) == C.ˋ(this.ॱˋ.ͺ)) {
                        this.ॱˋ = this.ॱˋ.ˏ(ॱ, this.ॱˋ.ͺ, j2, ॱˋ());
                        if (i != 0) {
                            this.ˊॱ.ˎ(2);
                            return;
                        }
                        return;
                    }
                }
                j3 = j;
                j3 = ˎ(ॱ, j3);
                i = (j != j3 ? 1 : 0) | i;
                j = j3;
            }
            this.ॱˋ = this.ॱˋ.ˏ(ॱ, j, j2, ॱˋ());
            if (i != 0) {
                this.ˊॱ.ˎ(2);
            }
        } catch (Throwable th) {
            Throwable th2 = th;
            this.ॱˋ = this.ॱˋ.ˏ(ॱ, j, j2, ॱˋ());
            if (i != 0) {
                this.ˊॱ.ˎ(2);
            }
        }
    }

    private long ˎ(o.aim.a aVar, long j) throws ExoPlaybackException {
        return ˊ(aVar, j, this.ॱˎ.ˋ() != this.ॱˎ.ˎ());
    }

    private long ˊ(o.aim.a aVar, long j, boolean z) throws ExoPlaybackException {
        ॱ();
        this.ʼॱ = false;
        ˏ(2);
        abj ˋ = this.ॱˎ.ˋ();
        abj o_abj = ˋ;
        while (o_abj != null) {
            if (aVar.equals(o_abj.ʻ.ˎ) && o_abj.ॱ) {
                this.ॱˎ.ˋ(o_abj);
                break;
            }
            o_abj = this.ॱˎ.ʽ();
        }
        if (ˋ != o_abj || z) {
            for (Renderer ॱ : this.ʿ) {
                ॱ(ॱ);
            }
            this.ʿ = new Renderer[0];
            ˋ = null;
        }
        if (o_abj != null) {
            ˎ(ˋ);
            if (o_abj.ʽ) {
                j = o_abj.ˎ.ˎ(j);
                o_abj.ˎ.ˎ(j - this.ˏॱ, this.ॱˊ);
            }
            ॱ(j);
            ॱˎ();
        } else {
            this.ॱˎ.ˋ(true);
            this.ॱˋ = this.ॱˋ.ˊ(TrackGroupArray.ˎ, this.ˏ);
            ॱ(j);
        }
        ʽ(false);
        this.ॱॱ.ˋ(2);
        return j;
    }

    private void ॱ(long j) throws ExoPlaybackException {
        if (this.ॱˎ.ॱॱ()) {
            j = this.ॱˎ.ˋ().ॱ(j);
        }
        this.ˋˊ = j;
        this.ˋॱ.ˋ(this.ˋˊ);
        for (Renderer ˋ : this.ʿ) {
            ˋ.ˋ(this.ˋˊ);
        }
    }

    private void ˋ(abq o_abq) {
        this.ˋॱ.ॱ(o_abq);
    }

    private void ˊ(abv o_abv) {
        this.ᐝॱ = o_abv;
    }

    private void ॱ(boolean z, boolean z2) {
        ˊ(true, z, z);
        this.ˊॱ.ˋ((z2 ? 1 : 0) + this.ˉ);
        this.ˉ = 0;
        this.ˎ.ˋ();
        ˏ(1);
    }

    private void ʻ() {
        ˊ(true, true, true);
        this.ˎ.ˊ();
        ˏ(1);
        this.ᐝ.quit();
        synchronized (this) {
            this.ʽॱ = true;
            notifyAll();
        }
    }

    private void ˊ(boolean z, boolean z2, boolean z3) {
        Throwable e;
        abr o_abr;
        Object obj;
        TrackGroupArray trackGroupArray;
        ala o_ala;
        this.ॱॱ.ˊ(2);
        this.ʼॱ = false;
        this.ˋॱ.ˎ();
        this.ˋˊ = 0;
        for (Renderer ॱ : this.ʿ) {
            try {
                ॱ(ॱ);
            } catch (ExoPlaybackException e2) {
                e = e2;
            } catch (RuntimeException e3) {
                e = e3;
            }
        }
        this.ʿ = new Renderer[0];
        this.ॱˎ.ˋ(!z2);
        ˊ(false);
        if (z2) {
            this.ˊᐝ = null;
        }
        if (z3) {
            this.ॱˎ.ˊ(abr.ˊ);
            Iterator it = this.ॱᐝ.iterator();
            while (it.hasNext()) {
                ((a) it.next()).ˎ.ˊ(false);
            }
            this.ॱᐝ.clear();
            this.ˎˎ = 0;
        }
        o.aim.a ॱ2 = z2 ? this.ॱˋ.ॱ(this.ˊˋ, this.ʻ) : this.ॱˋ.ॱ;
        long j = z2 ? -9223372036854775807L : this.ॱˋ.ͺ;
        long j2 = z2 ? -9223372036854775807L : this.ॱˋ.ˏ;
        if (z3) {
            o_abr = abr.ˊ;
        } else {
            o_abr = this.ॱˋ.ˊ;
        }
        if (z3) {
            obj = null;
        } else {
            obj = this.ॱˋ.ˎ;
        }
        int i = this.ॱˋ.ʻ;
        if (z3) {
            trackGroupArray = TrackGroupArray.ˎ;
        } else {
            trackGroupArray = this.ॱˋ.ʽ;
        }
        if (z3) {
            o_ala = this.ˏ;
        } else {
            o_ala = this.ॱˋ.ॱॱ;
        }
        this.ॱˋ = new abp(o_abr, obj, ॱ2, j, j2, i, false, trackGroupArray, o_ala, ॱ2, j, 0, j);
        if (z && this.ʾ != null) {
            this.ʾ.ˎ(this);
            this.ʾ = null;
            return;
        }
        return;
        amz.ˊ("ExoPlayerImplInternal", "Stop failed.", e);
    }

    private void ॱ(abn o_abn) throws ExoPlaybackException {
        if (o_abn.ʼ() == -9223372036854775807L) {
            ˊ(o_abn);
        } else if (this.ʾ == null || this.ˉ > 0) {
            this.ॱᐝ.add(new a(o_abn));
        } else {
            a aVar = new a(o_abn);
            if (ˋ(aVar)) {
                this.ॱᐝ.add(aVar);
                Collections.sort(this.ॱᐝ);
                return;
            }
            o_abn.ˊ(false);
        }
    }

    private void ˊ(abn o_abn) throws ExoPlaybackException {
        if (o_abn.ˎ().getLooper() == this.ॱॱ.ॱ()) {
            ˋ(o_abn);
            if (this.ॱˋ.ʻ == 3 || this.ॱˋ.ʻ == 2) {
                this.ॱॱ.ˋ(2);
                return;
            }
            return;
        }
        this.ॱॱ.ˎ(15, o_abn).sendToTarget();
    }

    private void ˎ(abn o_abn) {
        o_abn.ˎ().post(new abg(this, o_abn));
    }

    private /* synthetic */ void ʼ(abn o_abn) {
        try {
            ˋ(o_abn);
        } catch (Throwable e) {
            amz.ˊ("ExoPlayerImplInternal", "Unexpected error delivering message on external thread.", e);
            throw new RuntimeException(e);
        }
    }

    private void ˋ(abn o_abn) throws ExoPlaybackException {
        if (!o_abn.ᐝ()) {
            try {
                o_abn.ˋ().ˎ(o_abn.ˏ(), o_abn.ˊ());
            } finally {
                o_abn.ˊ(true);
            }
        }
    }

    private void ॱॱ() {
        for (int size = this.ॱᐝ.size() - 1; size >= 0; size--) {
            if (!ˋ((a) this.ॱᐝ.get(size))) {
                ((a) this.ॱᐝ.get(size)).ˎ.ˊ(false);
                this.ॱᐝ.remove(size);
            }
        }
        Collections.sort(this.ॱᐝ);
    }

    private boolean ˋ(a aVar) {
        if (aVar.ˏ == null) {
            Pair ˏ = ˏ(new b(aVar.ˎ.ॱ(), aVar.ˎ.ʻ(), C.ˏ(aVar.ˎ.ʼ())), false);
            if (ˏ == null) {
                return false;
            }
            aVar.ˏ(this.ॱˋ.ˊ.ˎ(ˏ.first), ((Long) ˏ.second).longValue(), ˏ.first);
        } else {
            int ˎ = this.ॱˋ.ˊ.ˎ(aVar.ˏ);
            if (ˎ == -1) {
                return false;
            }
            aVar.ˊ = ˎ;
        }
        return true;
    }

    private void ˋ(long j, long j2) throws ExoPlaybackException {
        if (!this.ॱᐝ.isEmpty() && !this.ॱˋ.ॱ.ˊ()) {
            if (this.ॱˋ.ˋ == j) {
                j--;
            }
            int ˎ = this.ॱˋ.ˊ.ˎ(this.ॱˋ.ॱ.ˋ);
            a aVar = this.ˎˎ > 0 ? (a) this.ॱᐝ.get(this.ˎˎ - 1) : null;
            while (aVar != null && (aVar.ˊ > ˎ || (aVar.ˊ == ˎ && aVar.ˋ > r8))) {
                this.ˎˎ--;
                aVar = this.ˎˎ > 0 ? (a) this.ॱᐝ.get(this.ˎˎ - 1) : null;
            }
            aVar = this.ˎˎ < this.ॱᐝ.size() ? (a) this.ॱᐝ.get(this.ˎˎ) : null;
            while (aVar != null && aVar.ˏ != null && (aVar.ˊ < ˎ || (aVar.ˊ == ˎ && aVar.ˋ <= r8))) {
                this.ˎˎ++;
                aVar = this.ˎˎ < this.ॱᐝ.size() ? (a) this.ॱᐝ.get(this.ˎˎ) : null;
            }
            while (aVar != null && aVar.ˏ != null && aVar.ˊ == ˎ && aVar.ˋ > r8 && aVar.ˋ <= j2) {
                ˊ(aVar.ˎ);
                if (aVar.ˎ.ʽ() || aVar.ˎ.ᐝ()) {
                    this.ॱᐝ.remove(this.ˎˎ);
                } else {
                    this.ˎˎ++;
                }
                if (this.ˎˎ < this.ॱᐝ.size()) {
                    aVar = (a) this.ॱᐝ.get(this.ˎˎ);
                } else {
                    aVar = null;
                }
            }
        }
    }

    private void ˎ(Renderer renderer) throws ExoPlaybackException {
        if (renderer.ˊ() == 2) {
            renderer.ˋॱ();
        }
    }

    private void ॱ(Renderer renderer) throws ExoPlaybackException {
        this.ˋॱ.ˋ(renderer);
        ˎ(renderer);
        renderer.ˊॱ();
    }

    private void ʽ() throws ExoPlaybackException {
        if (this.ॱˎ.ॱॱ()) {
            float f = this.ˋॱ.e_().ॱ;
            abj ˋ = this.ॱˎ.ˋ();
            abj ˎ = this.ॱˎ.ˎ();
            abj o_abj = ˋ;
            boolean z = true;
            while (o_abj != null && o_abj.ॱ) {
                if (o_abj.ˋ(f)) {
                    if (z) {
                        abj ˋ2 = this.ॱˎ.ˋ();
                        boolean[] zArr = new boolean[this.ˊ.length];
                        long ˋ3 = ˋ2.ˋ(this.ॱˋ.ͺ, this.ॱˎ.ˋ(ˋ2), zArr);
                        if (!(this.ॱˋ.ʻ == 4 || ˋ3 == this.ॱˋ.ͺ)) {
                            this.ॱˋ = this.ॱˋ.ˏ(this.ॱˋ.ॱ, ˋ3, this.ॱˋ.ˏ, ॱˋ());
                            this.ˊॱ.ˎ(4);
                            ॱ(ˋ3);
                        }
                        boolean[] zArr2 = new boolean[this.ˊ.length];
                        int i = 0;
                        for (int i2 = 0; i2 < this.ˊ.length; i2++) {
                            Renderer renderer = this.ˊ[i2];
                            zArr2[i2] = renderer.ˊ() != 0;
                            aiu o_aiu = ˋ2.ˊ[i2];
                            if (o_aiu != null) {
                                i++;
                            }
                            if (zArr2[i2]) {
                                if (o_aiu != renderer.ʼ()) {
                                    ॱ(renderer);
                                } else if (zArr[i2]) {
                                    renderer.ˋ(this.ˋˊ);
                                }
                            }
                        }
                        this.ॱˋ = this.ॱˋ.ˊ(ˋ2.ʼ, ˋ2.ᐝ);
                        ˋ(zArr2, i);
                    } else {
                        this.ॱˎ.ˋ(o_abj);
                        if (o_abj.ॱ) {
                            o_abj.ˋ(Math.max(o_abj.ʻ.ˊ, o_abj.ˏ(this.ˋˊ)), false);
                        }
                    }
                    ʽ(true);
                    if (this.ॱˋ.ʻ != 4) {
                        ॱˎ();
                        ʼ();
                        this.ॱॱ.ˋ(2);
                        return;
                    }
                    return;
                }
                if (o_abj == ˎ) {
                    z = false;
                }
                o_abj = o_abj.ॱॱ;
            }
        }
    }

    private void ॱ(float f) {
        for (abj ˏ = this.ॱˎ.ˏ(); ˏ != null; ˏ = ˏ.ॱॱ) {
            if (ˏ.ᐝ != null) {
                for (akz o_akz : ˏ.ᐝ.ˏ.ˊ()) {
                    if (o_akz != null) {
                        o_akz.ˋ(f);
                    }
                }
            }
        }
    }

    private boolean ॱॱ(boolean z) {
        if (this.ʿ.length == 0) {
            return ͺ();
        }
        if (!z) {
            return false;
        }
        if (!this.ॱˋ.ʼ) {
            return true;
        }
        boolean z2;
        abj ˊ = this.ॱˎ.ˊ();
        if (ˊ.ॱ() && ˊ.ʻ.ᐝ) {
            z2 = true;
        } else {
            z2 = false;
        }
        if (z2 || this.ˎ.ˏ(ॱˋ(), this.ˋॱ.e_().ॱ, this.ʼॱ)) {
            return true;
        }
        return false;
    }

    private boolean ͺ() {
        abj ˋ = this.ॱˎ.ˋ();
        long j = ˋ.ʻ.ˏ;
        return j == -9223372036854775807L || this.ॱˋ.ͺ < j || (ˋ.ॱॱ != null && (ˋ.ॱॱ.ॱ || ˋ.ॱॱ.ʻ.ˎ.ˊ()));
    }

    private void ˊॱ() throws IOException {
        if (this.ॱˎ.ˊ() != null) {
            Renderer[] rendererArr = this.ʿ;
            int length = rendererArr.length;
            int i = 0;
            while (i < length) {
                if (rendererArr[i].ᐝ()) {
                    i++;
                } else {
                    return;
                }
            }
        }
        this.ʾ.ॱ();
    }

    private void ॱˊ() throws IOException {
        abj ˊ = this.ॱˎ.ˊ();
        abj ˎ = this.ॱˎ.ˎ();
        if (ˊ != null && !ˊ.ॱ) {
            if (ˎ == null || ˎ.ॱॱ == ˊ) {
                Renderer[] rendererArr = this.ʿ;
                int length = rendererArr.length;
                int i = 0;
                while (i < length) {
                    if (rendererArr[i].ᐝ()) {
                        i++;
                    } else {
                        return;
                    }
                }
                ˊ.ˎ.h_();
            }
        }
    }

    private void ˎ(c cVar) throws ExoPlaybackException {
        long j = 0;
        if (cVar.ˎ == this.ʾ) {
            abr o_abr = this.ॱˋ.ˊ;
            abr o_abr2 = cVar.ॱ;
            Object obj = cVar.ˋ;
            this.ॱˎ.ˊ(o_abr2);
            this.ॱˋ = this.ॱˋ.ˋ(o_abr2, obj);
            ॱॱ();
            Pair ˏ;
            Object obj2;
            long longValue;
            o.aim.a ॱ;
            abp o_abp;
            long j2;
            if (this.ˉ > 0) {
                this.ˊॱ.ˋ(this.ˉ);
                this.ˉ = 0;
                if (this.ˊᐝ != null) {
                    try {
                        ˏ = ˏ(this.ˊᐝ, true);
                        this.ˊᐝ = null;
                        if (ˏ == null) {
                            ˏॱ();
                            return;
                        }
                        obj2 = ˏ.first;
                        longValue = ((Long) ˏ.second).longValue();
                        ॱ = this.ॱˎ.ॱ(obj2, longValue);
                        o_abp = this.ॱˋ;
                        if (ॱ.ˊ()) {
                            j2 = 0;
                        } else {
                            j2 = longValue;
                        }
                        this.ॱˋ = o_abp.ˎ(ॱ, j2, longValue);
                    } catch (IllegalSeekPositionException e) {
                        IllegalSeekPositionException illegalSeekPositionException = e;
                        this.ॱˋ = this.ॱˋ.ˎ(this.ॱˋ.ॱ(this.ˊˋ, this.ʻ), -9223372036854775807L, -9223372036854775807L);
                        throw illegalSeekPositionException;
                    }
                } else if (this.ॱˋ.ˋ != -9223372036854775807L) {
                } else {
                    if (o_abr2.ˏ()) {
                        ˏॱ();
                        return;
                    }
                    ˏ = ˋ(o_abr2, o_abr2.ˏ(this.ˊˋ), -9223372036854775807L);
                    obj2 = ˏ.first;
                    longValue = ((Long) ˏ.second).longValue();
                    ॱ = this.ॱˎ.ॱ(obj2, longValue);
                    o_abp = this.ॱˋ;
                    if (ॱ.ˊ()) {
                        j2 = 0;
                    } else {
                        j2 = longValue;
                    }
                    this.ॱˋ = o_abp.ˎ(ॱ, j2, longValue);
                }
            } else if (!o_abr.ˏ()) {
                abj ˏ2 = this.ॱˎ.ˏ();
                longValue = this.ॱˋ.ˏ;
                obj = ˏ2 == null ? this.ॱˋ.ॱ.ˋ : ˏ2.ˋ;
                if (o_abr2.ˎ(obj) == -1) {
                    obj = ॱ(obj, o_abr, o_abr2);
                    if (obj == null) {
                        ˏॱ();
                        return;
                    }
                    ˏ = ˋ(o_abr2, o_abr2.ॱ(obj, this.ͺ).ॱ, -9223372036854775807L);
                    obj2 = ˏ.first;
                    longValue = ((Long) ˏ.second).longValue();
                    ॱ = this.ॱˎ.ॱ(obj2, longValue);
                    if (ˏ2 != null) {
                        abj o_abj = ˏ2;
                        while (o_abj.ॱॱ != null) {
                            o_abj = o_abj.ॱॱ;
                            if (o_abj.ʻ.ˎ.equals(ॱ)) {
                                o_abj.ʻ = this.ॱˎ.ˋ(o_abj.ʻ);
                            }
                        }
                    }
                    if (!ॱ.ˊ()) {
                        j = longValue;
                    }
                    this.ॱˋ = this.ॱˋ.ˏ(ॱ, ˎ(ॱ, j), longValue, ॱˋ());
                    return;
                }
                o.aim.a aVar = this.ॱˋ.ॱ;
                if (aVar.ˊ()) {
                    ॱ = this.ॱˎ.ॱ(obj, longValue);
                    if (!ॱ.equals(aVar)) {
                        if (!ॱ.ˊ()) {
                            j = longValue;
                        }
                        this.ॱˋ = this.ॱˋ.ˏ(ॱ, ˎ(ॱ, j), longValue, ॱˋ());
                        return;
                    }
                }
                if (!this.ॱˎ.ॱ(aVar, this.ˋˊ)) {
                    ʼ(false);
                }
                ʽ(false);
            } else if (!o_abr2.ˏ()) {
                ˏ = ˋ(o_abr2, o_abr2.ˏ(this.ˊˋ), -9223372036854775807L);
                obj2 = ˏ.first;
                longValue = ((Long) ˏ.second).longValue();
                ॱ = this.ॱˎ.ॱ(obj2, longValue);
                o_abp = this.ॱˋ;
                if (ॱ.ˊ()) {
                    j2 = 0;
                } else {
                    j2 = longValue;
                }
                this.ॱˋ = o_abp.ˎ(ॱ, j2, longValue);
            }
        }
    }

    private void ˏॱ() {
        ˏ(4);
        ˊ(false, true, false);
    }

    @Nullable
    private Object ॱ(Object obj, abr o_abr, abr o_abr2) {
        int ˎ = o_abr.ˎ(obj);
        int ˎ2 = o_abr.ˎ();
        int i = 0;
        int i2 = -1;
        while (i < ˎ2 && i2 == -1) {
            int ˎ3 = o_abr.ˎ(ˎ, this.ͺ, this.ʻ, this.ˊˊ, this.ˊˋ);
            if (ˎ3 == -1) {
                break;
            }
            i++;
            i2 = o_abr2.ˎ(o_abr.ˋ(ˎ3));
            ˎ = ˎ3;
        }
        return i2 == -1 ? null : o_abr2.ˋ(i2);
    }

    private Pair<Object, Long> ˏ(b bVar, boolean z) {
        abr o_abr = this.ॱˋ.ˊ;
        abr o_abr2 = bVar.ˏ;
        if (o_abr.ˏ()) {
            return null;
        }
        if (o_abr2.ˏ()) {
            o_abr2 = o_abr;
        }
        try {
            Pair<Object, Long> ˏ = o_abr2.ˏ(this.ʻ, this.ͺ, bVar.ˊ, bVar.ॱ);
            if (o_abr == o_abr2) {
                return ˏ;
            }
            int ˎ = o_abr.ˎ(ˏ.first);
            if (ˎ != -1) {
                return ˏ;
            }
            return (!z || ॱ(ˏ.first, o_abr2, o_abr) == null) ? null : ˋ(o_abr, o_abr.ˏ(ˎ, this.ͺ).ॱ, -9223372036854775807L);
        } catch (IndexOutOfBoundsException e) {
            throw new IllegalSeekPositionException(o_abr, bVar.ˊ, bVar.ॱ);
        }
    }

    private Pair<Object, Long> ˋ(abr o_abr, int i, long j) {
        return o_abr.ˏ(this.ʻ, this.ͺ, i, j);
    }

    private void ˋॱ() throws ExoPlaybackException, IOException {
        int i = 0;
        if (this.ʾ != null) {
            if (this.ˉ > 0) {
                this.ʾ.ॱ();
                return;
            }
            ॱᐝ();
            abj ˊ = this.ॱˎ.ˊ();
            if (ˊ == null || ˊ.ॱ()) {
                ˊ(false);
            } else if (!this.ॱˋ.ʼ) {
                ॱˎ();
            }
            if (this.ॱˎ.ॱॱ()) {
                ˊ = this.ॱˎ.ˋ();
                abj ˎ = this.ॱˎ.ˎ();
                abj o_abj = ˊ;
                int i2 = 0;
                while (this.ˈ && o_abj != ˎ && this.ˋˊ >= o_abj.ॱॱ.ˏ()) {
                    int i3;
                    if (i2 != 0) {
                        ˋ();
                    }
                    if (o_abj.ʻ.ˋ) {
                        i3 = 0;
                    } else {
                        i3 = 3;
                    }
                    abj ʽ = this.ॱˎ.ʽ();
                    ˎ(o_abj);
                    this.ॱˋ = this.ॱˋ.ˏ(ʽ.ʻ.ˎ, ʽ.ʻ.ˊ, ʽ.ʻ.ॱ, ॱˋ());
                    this.ˊॱ.ˎ(i3);
                    ʼ();
                    i2 = 1;
                    o_abj = ʽ;
                }
                if (ˎ.ʻ.ᐝ) {
                    while (i < this.ˊ.length) {
                        Renderer renderer = this.ˊ[i];
                        aiu o_aiu = ˎ.ˊ[i];
                        if (o_aiu != null && renderer.ʼ() == o_aiu && renderer.ᐝ()) {
                            renderer.ʽ();
                        }
                        i++;
                    }
                } else if (ˎ.ॱॱ != null) {
                    i2 = 0;
                    while (i2 < this.ˊ.length) {
                        Renderer renderer2 = this.ˊ[i2];
                        aiu o_aiu2 = ˎ.ˊ[i2];
                        if (renderer2.ʼ() != o_aiu2) {
                            return;
                        }
                        if (o_aiu2 == null || renderer2.ᐝ()) {
                            i2++;
                        } else {
                            return;
                        }
                    }
                    if (ˎ.ॱॱ.ॱ) {
                        ala o_ala = ˎ.ᐝ;
                        abj ᐝ = this.ॱˎ.ᐝ();
                        ala o_ala2 = ᐝ.ᐝ;
                        if (ᐝ.ˎ.ˎ() != -9223372036854775807L) {
                            i2 = 1;
                        } else {
                            i2 = 0;
                        }
                        for (int i4 = 0; i4 < this.ˊ.length; i4++) {
                            Renderer renderer3 = this.ˊ[i4];
                            if (o_ala.ˏ(i4)) {
                                if (i2 != 0) {
                                    renderer3.ʽ();
                                } else if (!renderer3.ʻ()) {
                                    akz ˊ2 = o_ala2.ˏ.ˊ(i4);
                                    boolean ˏ = o_ala2.ˏ(i4);
                                    int i5 = this.ॱ[i4].f_() == 6 ? 1 : 0;
                                    Object obj = o_ala.ॱ[i4];
                                    abs o_abs = o_ala2.ॱ[i4];
                                    if (ˏ && o_abs.equals(obj) && i5 == 0) {
                                        renderer3.ˋ(ˊ(ˊ2), ᐝ.ˊ[i4], ᐝ.ˋ());
                                    } else {
                                        renderer3.ʽ();
                                    }
                                }
                            }
                        }
                        return;
                    }
                    ॱˊ();
                }
            }
        }
    }

    private void ॱᐝ() throws IOException {
        this.ॱˎ.ˊ(this.ˋˊ);
        if (this.ॱˎ.ॱ()) {
            abl ˏ = this.ॱˎ.ˏ(this.ˋˊ, this.ॱˋ);
            if (ˏ == null) {
                ˊॱ();
                return;
            }
            this.ॱˎ.ˋ(this.ॱ, this.ˋ, this.ˎ.ˎ(), this.ʾ, ˏ).ˏ(this, ˏ.ˊ);
            ˊ(true);
            ʽ(false);
        }
    }

    private void ˎ(aih o_aih) throws ExoPlaybackException {
        if (this.ॱˎ.ˏ(o_aih)) {
            abj ˊ = this.ॱˎ.ˊ();
            ˊ.ˏ(this.ˋॱ.e_().ॱ);
            ˎ(ˊ.ʼ, ˊ.ᐝ);
            if (!this.ॱˎ.ॱॱ()) {
                ॱ(this.ॱˎ.ʽ().ʻ.ˊ);
                ˎ(null);
            }
            ॱˎ();
        }
    }

    private void ॱ(aih o_aih) {
        if (this.ॱˎ.ˏ(o_aih)) {
            this.ॱˎ.ˊ(this.ˋˊ);
            ॱˎ();
        }
    }

    private void ˊ(abq o_abq) throws ExoPlaybackException {
        this.ʽ.obtainMessage(1, o_abq).sendToTarget();
        ॱ(o_abq.ॱ);
        for (Renderer renderer : this.ˊ) {
            if (renderer != null) {
                renderer.ॱ(o_abq.ॱ);
            }
        }
    }

    private void ॱˎ() {
        abj ˊ = this.ॱˎ.ˊ();
        long ˊ2 = ˊ.ˊ();
        if (ˊ2 == Long.MIN_VALUE) {
            ˊ(false);
            return;
        }
        boolean ˏ = this.ˎ.ˏ(ˎ(ˊ2), this.ˋॱ.e_().ॱ);
        ˊ(ˏ);
        if (ˏ) {
            ˊ.ˎ(this.ˋˊ);
        }
    }

    private void ˎ(@Nullable abj o_abj) throws ExoPlaybackException {
        abj ˋ = this.ॱˎ.ˋ();
        if (ˋ != null && o_abj != ˋ) {
            boolean[] zArr = new boolean[this.ˊ.length];
            int i = 0;
            int i2 = 0;
            while (i < this.ˊ.length) {
                boolean z;
                Renderer renderer = this.ˊ[i];
                if (renderer.ˊ() != 0) {
                    z = true;
                } else {
                    z = false;
                }
                zArr[i] = z;
                if (ˋ.ᐝ.ˏ(i)) {
                    i2++;
                }
                if (zArr[i] && (!ˋ.ᐝ.ˏ(i) || (renderer.ʻ() && renderer.ʼ() == o_abj.ˊ[i]))) {
                    ॱ(renderer);
                }
                i++;
            }
            this.ॱˋ = this.ॱˋ.ˊ(ˋ.ʼ, ˋ.ᐝ);
            ˋ(zArr, i2);
        }
    }

    private void ˋ(boolean[] zArr, int i) throws ExoPlaybackException {
        int i2 = 0;
        this.ʿ = new Renderer[i];
        abj ˋ = this.ॱˎ.ˋ();
        int i3 = 0;
        while (i2 < this.ˊ.length) {
            if (ˋ.ᐝ.ˏ(i2)) {
                int i4 = i3 + 1;
                ˋ(i2, zArr[i2], i3);
                i3 = i4;
            }
            i2++;
        }
    }

    private void ˋ(int i, boolean z, int i2) throws ExoPlaybackException {
        boolean z2 = true;
        abj ˋ = this.ॱˎ.ˋ();
        Renderer renderer = this.ˊ[i];
        this.ʿ[i2] = renderer;
        if (renderer.ˊ() == 0) {
            abs o_abs = ˋ.ᐝ.ॱ[i];
            Format[] ˊ = ˊ(ˋ.ᐝ.ˏ.ˊ(i));
            boolean z3 = this.ˈ && this.ॱˋ.ʻ == 3;
            if (z || !z3) {
                z2 = false;
            }
            renderer.ॱ(o_abs, ˊ, ˋ.ˊ[i], this.ˋˊ, z2, ˋ.ˋ());
            this.ˋॱ.ˎ(renderer);
            if (z3) {
                renderer.ˏ();
            }
        }
    }

    private boolean ˋ(Renderer renderer) {
        abj ˎ = this.ॱˎ.ˎ();
        return ˎ.ॱॱ != null && ˎ.ॱॱ.ॱ && renderer.ᐝ();
    }

    private void ʽ(boolean z) {
        long j;
        abj ˊ = this.ॱˎ.ˊ();
        o.aim.a aVar = ˊ == null ? this.ॱˋ.ॱ : ˊ.ʻ.ˎ;
        Object obj = !this.ॱˋ.ᐝ.equals(aVar) ? 1 : null;
        if (obj != null) {
            this.ॱˋ = this.ॱˋ.ˎ(aVar);
        }
        abp o_abp = this.ॱˋ;
        if (ˊ == null) {
            j = this.ॱˋ.ͺ;
        } else {
            j = ˊ.ˎ();
        }
        o_abp.ॱˊ = j;
        this.ॱˋ.ˋॱ = ॱˋ();
        if ((obj != null || z) && ˊ != null && ˊ.ॱ) {
            ˎ(ˊ.ʼ, ˊ.ᐝ);
        }
    }

    private long ॱˋ() {
        return ˎ(this.ॱˋ.ॱˊ);
    }

    private long ˎ(long j) {
        abj ˊ = this.ॱˎ.ˊ();
        if (ˊ == null) {
            return 0;
        }
        return j - ˊ.ˏ(this.ˋˊ);
    }

    private void ˎ(TrackGroupArray trackGroupArray, ala o_ala) {
        this.ˎ.ॱ(this.ˊ, trackGroupArray, o_ala.ˏ);
    }

    private static Format[] ˊ(akz o_akz) {
        int ॱ;
        int i = 0;
        if (o_akz != null) {
            ॱ = o_akz.ॱ();
        } else {
            ॱ = 0;
        }
        Format[] formatArr = new Format[ॱ];
        while (i < ॱ) {
            formatArr[i] = o_akz.ॱ(i);
            i++;
        }
        return formatArr;
    }
}
